home *** CD-ROM | disk | FTP | other *** search
/ CD BIT 75 / CD BIT 75.iso / Software / ooo / f_0020 / sbasic.jar / text / sbasic / common / 01010210.xml < prev    next >
Encoding:
Extensible Markup Language  |  2003-08-01  |  4.8 KB  |  30 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <html><head><title>Basics</title><meta name="filename" content="text/sbasic/common/01010210"/><help:css-file-link xmlns:help="http://openoffice.org/2000/help"/><!--The CSS style header method for setting styles--><style type="text/css">
  3.  
  4.         p.P1{
  5.                 }
  6.         p.P2{
  7.                 }
  8.         span.T1{
  9.                 font-weight:bold;}
  10.         </style></head><body>
  11.   
  12.   
  13.   <help:paragraphinfo state="E" xmlns:help="http://openoffice.org/2000/help"/><help:to-be-embedded Eid="modular" xmlns:help="http://openoffice.org/2000/help">
  14.   <p class="Head1"><help:paragraphinfo state="U" number="1"/><help:link Id="66575">Basics</help:link></p>
  15.   <p class="Paragraph"><help:paragraphinfo state="U" number="14"/>This section provides the fundamentals for working with <help:productname>%PRODUCTNAME</help:productname> Basic.</p>
  16.   <help:paragraphinfo state="E"/></help:to-be-embedded>
  17.   <p class="Paragraph"><help:paragraphinfo state="U" number="2" xmlns:help="http://openoffice.org/2000/help"/><help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname> Basic code is based on subroutines and functions that are specified between <span class="T1">sub...end┬ásub</span> and <span class="T1">function...end┬áfunction</span> sections. Each Sub or Function can call other Subs and Functions. If you take care to write generic code for a Sub or Function, you can probably re-use it in other programs. See also <help:link Id="66513" xmlns:help="http://openoffice.org/2000/help">Procedures and Functions</help:link>.</p>
  18.   <p class="Head2"><help:paragraphinfo state="U" number="3" xmlns:help="http://openoffice.org/2000/help"/>What is a Sub?</p>
  19.   <p class="Paragraph"><help:paragraphinfo state="U" number="4" xmlns:help="http://openoffice.org/2000/help"/><span class="T1">Sub</span> is the short form of <span class="T1">subroutine</span>, that is used to handle a certain task within a program. Subs are used to split a task into individual procedures. Splitting a program into procedures and sub-procedures enhances readability and reduces the error-proneness. A sub possibly takes some arguments as parameters <text:s text:c="" xmlns:text="http://openoffice.org/2000/text"/>but does not return any values back to the calling sub or function, for example:</p>
  20.   <p class="P2"><help:paragraphinfo state="U" number="15" xmlns:help="http://openoffice.org/2000/help"/>DoSomethingWithTheValues(MyFirstValue,MySecondValue)</p>
  21.   <p class="Head2"><help:paragraphinfo state="U" number="5" xmlns:help="http://openoffice.org/2000/help"/>What is a Function?</p>
  22.   <p class="Paragraph"><help:paragraphinfo state="U" number="6" xmlns:help="http://openoffice.org/2000/help"/>A <span class="T1">function</span> is essentially a sub, which returns a value. You may use a function at the right side of a variable declaration, or at other places where you normally use values, for example:</p>
  23.   <p class="Paragraph"><help:paragraphinfo state="U" number="7" xmlns:help="http://openoffice.org/2000/help"/><span class="T1">MySecondValue = myFunction(MyFirstValue)</span></p>
  24.   <p class="Head2"><help:paragraphinfo state="U" number="8" xmlns:help="http://openoffice.org/2000/help"/>Global and local variables</p>
  25.   <p class="Paragraph"><help:paragraphinfo state="U" number="9" xmlns:help="http://openoffice.org/2000/help"/>Global variables are valid for all subs and functions inside a module. They are declared at the beginning of a module before the first sub or function starts.</p>
  26.   <p class="Paragraph"><help:paragraphinfo state="U" number="10" xmlns:help="http://openoffice.org/2000/help"/>Variables that you declare within a sub or function are valid only inside this sub or function. These variables override global variables with the same name and local variables with the same name coming from superordinate subs or functions.</p>
  27.   <p class="Head2"><help:paragraphinfo state="U" number="11" xmlns:help="http://openoffice.org/2000/help"/>Structuring</p>
  28.   <p class="Paragraph"><help:paragraphinfo state="U" number="12" xmlns:help="http://openoffice.org/2000/help"/>After separating your program into procedures and functions (Subs and Functions), you can save these procedures and functions as files for reuse in other projects. <help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname> Basic supports <help:link Id="66460" xmlns:help="http://openoffice.org/2000/help">Modules and Libraries</help:link>. Subs and functions are always contained in modules. You can define modules to be global or part of a document. Multiple modules can be combined to a library.</p>
  29.   <p class="Paragraph"><help:paragraphinfo state="U" number="13" xmlns:help="http://openoffice.org/2000/help"/>You can copy or move subs, functions, modules and libraries from one file to another by using the <help:link Id="68327" xmlns:help="http://openoffice.org/2000/help">Macro</help:link> dialog.</p>
  30.  </body></html>